<?php
/**
 * 筛选条件
 */

namespace app\badmin\controller;


use app\badmin\model\CompanyShop as CompanyShopModel;
use app\common\controller\BadminController;
use think\Exception;

class Where extends BadminController {

    protected $isArrayResult = ['selectshop'];

    /**
     * 门店列表
     * @return false|string
     */
    public function selectShop() {
        try {
            $params = $this->checkParams('');
            if ($params === false) return $this->resErr();
            if ($params['account_type'] == 0) {
                $res = CompanyShopModel::getDatas([['company_id', '=', $params['company_id']], ['deleted', '=', 0]], 'name,id');
                array_unshift($res, ['name' => '直属公司', 'id' => 0]);
            } else {
                $res = CompanyShopModel::getDatas([['id', '=', $params['company_shop_id']], ['deleted', '=', 0]], 'name,id');
            }
            return $this->resData('success', $res);
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 用户状态
     * @return false|string
     */
    public function selectUserStatus() {
        try {
            $params = $this->checkParams('');
            if ($params === false) return $this->resErr();
            $res = [
                ['key' => 1, 'value' => '潜在客户'],
                ['key' => 2, 'value' => '专属客户']
            ];
            return $this->resData('success', $res);
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }


}